home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / insight / plugins / mybias0.pro < prev    next >
Text File  |  1997-07-08  |  6KB  |  156 lines

  1. ; $Id: mybias0.pro,v 1.4 1997/04/22 17:12:33 rob Exp $
  2. ;
  3. ; Copyright (c) 1997, Research Systems, Inc.  All rights reserved.
  4. ;   Unauthorized reproduction prohibited.
  5. ;+
  6. ; FILE:
  7. ;       mybias0.pro
  8. ;
  9. ; PURPOSE:
  10. ;       This file contains an example Analysis PlugIn that biases data,
  11. ;       without a dialog.  Note only the Apply callback is used.
  12. ;       (See mybias.pro for an example with a normal Analysis dialog.)
  13. ;
  14. ; CONTENTS:
  15. ;       CALLBACK ROUTINES
  16. ;           fun ApplyMyBias0            - main entry point
  17. ;
  18. ;       REGISTRATION FUNCTION
  19. ;           fun MyBias0                 - registers the PlugIn
  20. ;
  21. ;-
  22.  
  23. ; *****************************************************************************
  24. ;       CALLBACK ROUTINES
  25. ; *****************************************************************************
  26.  
  27. ; -----------------------------------------------------------------------------
  28. ;
  29. ;   Purpose:  Get data and bias it (called when PlugIn menu item selected).
  30. ;             Use the data selected in the vis window, else prompt user.
  31. ;             Fuction returns 1B on success, else 0B.
  32. ;
  33. function ApplyMyBias0, $
  34.     CIDs=CIDs, $            ; OUT: command ID list from INSPUT/INSVIS calls
  35.     GROUP=wGroup, $         ; IN: group leader widget ID
  36.     DATA_NAME=dataName, $   ; IN: name of data selected in visualization window
  37.     _EXTRA=extra            ; IN: information to pass to commands
  38.  
  39.     ; ---------------------------------------------------------
  40.     ;  Catch errors.
  41.     ; ---------------------------------------------------------
  42.  
  43.     CATCH, error
  44.     if (error ne 0) then begin
  45.         CATCH, /CANCEL
  46.         void = DIALOG_MESSAGE(!ERR_STRING, DIALOG_PARENT=wGroup)
  47.         RETURN, 0B
  48.     endif
  49.  
  50.     ; ---------------------------------------------------------
  51.     ;  Get the data.
  52.     ; ---------------------------------------------------------
  53.  
  54.     ;  If no data selected, prompt the user for data.
  55.     ;
  56.     if (dataName eq '') then $
  57.         inputData = INSGET( $           ; prompt the user for data
  58.             COUNT=count, $
  59.             DIMS_LIST=1, $
  60.             NAME=dataNameUse, $
  61.             /EXCLUSIVE, $
  62.             GROUP=wGroup, $
  63.             _EXTRA=extra) $
  64.     else begin
  65.         dataNameUse = dataName
  66.         inputData = INSGET( $           ; just get the data (no prompt)
  67.             dataNameUse, $
  68.             COUNT=count, $
  69.             DIMS_LIST=1, $
  70.             GROUP=wGroup, $
  71.             _EXTRA=extra)
  72.     endelse
  73.  
  74.     ;  Return if data not obtained.
  75.     ;
  76.     if (count ne 1) then $
  77.         RETURN, 0B
  78.  
  79.     ; ---------------------------------------------------------
  80.     ;  Perform biasing.
  81.     ; ---------------------------------------------------------
  82.  
  83.     minVal = MIN(inputData, MAX=maxVal)
  84.     bias = 0.3 * (maxVal - minVal)
  85.     newData = inputData + bias
  86.  
  87.     ; ---------------------------------------------------------
  88.     ;  Put the new data into Insight.
  89.     ; ---------------------------------------------------------
  90.  
  91.     description = 'Biased "' + dataNameUse + '" by ' + $
  92.         STRING(STRCOMPRESS(bias, /REMOVE_ALL)) + '.'
  93.     outputName = 'Bias0 Output'
  94.  
  95.     INSPUT, $
  96.         newData             , $                 ; the data
  97.         DESCRIPTION         = description, $    ; data description
  98.         NAME                = outputName, $     ; try this data name
  99.         NEW_NAME            = outputNameUsed, $ ; the data name actually used
  100.         REPLACE             = 2, $              ; prompt user if name conflict
  101.         COUNT               = count, $          ; returned # of items put
  102.         CIDs                = CIDs, $           ; command ID list
  103.         GROUP               = wGroup, $         ; widget group leader
  104.         _EXTRA              = extra             ; extra information
  105.  
  106.     ;  Return if "put" failed.
  107.     ;
  108.     if (count ne 1) then $
  109.         RETURN, 0B
  110.  
  111.     ; ---------------------------------------------------------
  112.     ;  Visualize new data item.
  113.     ; ---------------------------------------------------------
  114.  
  115.     INSVIS, $
  116.         outputNameUsed, $                       ; name of data item
  117.         TYPE                = 'plot', $         ; visualization type
  118.         MODE                = 'new', $          ; insert | new | overlay
  119.         CIDs                = CIDs, $           ; command ID list
  120.         GROUP               = wGroup, $         ; widget group leader
  121.         _EXTRA              = extra             ; extra information
  122.  
  123.     ; ---------------------------------------------------------
  124.     ;  Successful return.
  125.     ; ---------------------------------------------------------
  126.  
  127.     RETURN, 1B
  128.  
  129. end                 ; ApplyMyBias0
  130.  
  131. ; *****************************************************************************
  132. ;       REGISTRATION FUNCTION
  133. ; *****************************************************************************
  134.  
  135. ; -----------------------------------------------------------------------------
  136. ;
  137. ;   Purpose:  Register the Analysis PlugIn.
  138. ;
  139. function MyBias0
  140.  
  141.     ;  Return the Analysis PlugIn Registration Structure.
  142.     ;
  143.     RETURN, { $
  144.         type:       'Analysis_PlugIn', $            ; PlugIn type
  145.         title:      'My Bias 0', $                  ; PlugIn title
  146.         purpose:    'Bias by 30%.', $               ; PlugIn purpose
  147.         main_proc:  '', $                           ; (no GUI, so empty)
  148.         apply_func: 'ApplyMyBias0', $               ; apply callback
  149.         version:    '5.0', $                        ; IDL version
  150.         revision:   '1.0' $                         ; PlugIn version
  151.         }
  152.  
  153. end                 ; MyBias0
  154.  
  155. ; -----------------------------------------------------------------------------
  156.